﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Talk.Net
{
	class DigitalSignalProcessor
	{
		public static byte[] CleanseA(byte[] raw, int size)
		{

			int min, max;

			for (int i = 0; i < raw.Length; i = i + size)
			{
				min = int.MaxValue;
				max = int.MinValue;

				for (int j = i; j < Math.Min(i + size, raw.Length); j++)
				{
					min = Math.Min(min, (int)raw[j]);
					max = Math.Max(max, (int)raw[j]);
				}
				if (Math.Abs(max - min) < 10)
				{
					for (int j = i; j < Math.Min(i + size, raw.Length); j++)
					{
						raw[j] = (byte)0;
					}
				}
			}
			return raw;
		}
	}
}
